package cn.wolfcode.wolf2w.job;

import cn.wolfcode.wolf2w.cache.service.IStrategyStatisRedisService;
import cn.wolfcode.wolf2w.cache.service.vo.StrategyStatisVO;
import cn.wolfcode.wolf2w.domain.Strategy;
import cn.wolfcode.wolf2w.service.IStrategyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * redis持久化
 */
@Component
public class RedisDataPersistenceJob {
    @Autowired
    private IStrategyStatisRedisService strategyStatisRedisService;
    @Autowired
    private IStrategyService strategyService;

    @Scheduled(cron = "0/10 * * * * ? ")
    public void doWork() {

        System.out.println("............vo持久化.....start......");
        List<StrategyStatisVO> vos = strategyStatisRedisService.queryStaraategyVoByPattern("*");

        for (StrategyStatisVO strategyStatisVO : vos) {
            strategyService.updateStrategtVo(strategyStatisVO );
        }

        System.out.println("............vo持久化.....end......");
    }
}